<?php
class City extends Controller {
	function City() {
		parent::Controller();
	}

	function showAll() {
		$this->load->model('city_model');
		$data['title'] = 'Frool';
		$data['cities'] = $this->city_model->readAll();
		$theme = $this->config->item('active_theme');
		$data['content'] = $this->load->view($theme.'city/showAll', $data, true);
		$this->load->view($theme.'layout', $data);
	}

	function add() {
		$this->load->model('city_model');
		if ($this->input->post('Submit')) {
			$this->city_model->create();
			redirect('city/showAll');
		}
		$data['title'] = 'Frool';
		$theme = $this->config->item('active_theme');
		$data['content'] = $this->load->view($theme.'city/add', $data, true);
		$this->load->view($theme.'layout', $data);
	}

	function edit($id) {
		$this->load->model('city_model');
		if ($this->input->post('Submit')) {
			$this->city_model->update($id);
			redirect('city/showAll');
		}
		$data['title'] = 'Frool';
		$data['city'] = $this->city_model->read($id);
		$theme = $this->config->item('active_theme');
		$data['content'] = $this->load->view($theme.'city/edit', $data, true);
		$this->load->view($theme.'layout', $data);
	}
}
?>
